<include file="/public/header" />
<!-- 重定位style -->
<style>
    .fileManager li:hover {
        background-color: #f7f7f7;
        cursor: pointer;
    }   
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div id="fileManager" lay-filter="fileManager" ></div>
    </div>
</div>

<include file="/public/footer" />
<script>
    layui.use(['admin','table','fileManager','upload'], function () {
        var admin = layui.admin;
        var jquery = layui.jquery;
        var upload = layui.upload;
        var fileManager = layui.fileManager;
        /*
            后期会重写这部分源码！界面有点太简单了！
            不过开源作者也不易，支持下，毕竟用人的组件！
            暂时就这样吧，要写的话，很多东西要全部进行重构！
        */
        fileManager.render({
            id: 'files'
            ,method:'post'
            ,btn_upload: true
            ,btn_create: true
            ,elem: '#fileManager'
            ,url: "{:url('/system.adminfile/index')}"
            ,parseData: function (res) {
                let _res = [];
                _res.code = 0;
                _res.data = res.images;
                _res.count = res.count
                return _res;
            }
            ,done: function (res,curr,count) {
            }
            ,page: {
                limit:30
            }
            ,where: {
                action: 'get_file_data'
            }
        });

        var upIns = upload.render({
            elem: '#uploadfile' //绑定元素
            ,url: "{:url('/upload/upload')}" //上传接口
            ,done:function(res, index, upload){
                if (res.code == 200) {
                    layui.iziToast.success({
                        message: res.msg,
                    });  
                    fileManager.reload('files');
                }
            }
        })

        fileManager.on('uploadfile(files)', function(obj){
            upIns();
        });

        //监听新建文件夹事件
        fileManager.on('new_dir(files)', function(obj){
            layui.iziToast.info({
                message:"暂未写接口！",
            });  
        });
    })
</script>
